// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
//$.fx.speeds._default = 1000;
$(function(){
    //    $("a").each(function(){
    //        $(this).attr("href", $(this).attr("href")+"#")
    //    })
    $("#login-form").dialog({
        height: 220,
        width: 400,
        title: "会员登录",
        autoOpen: false,
        show: 'blind',
        hide: 'explode'
    })
    $("#pop_set_photo").dialog({
        height: 430,
        width: 460,
        title: "上传图片",
        autoOpen: false,
        show: 'blind',
        hide: 'explode'
    })
    $("#album_new_form").dialog({
        height: 260,
        width: 360,
        title: "创建相册",
        autoOpen: false,
        show: 'blind',
        hide: 'explode'
    })
    $("[id*=to_login_href]").click(function(){
        $("#login-form").dialog("open")
    })
    $("#startUpload").click(function(){
        $("#pop_set_photo").dialog("open")
    })
    $("#upload_photo_cancel").click(function(){
        $("#pop_set_photo").dialog("close")
    })
    $("#upload_photo_ok").click(function(){
        $("#local_upload_form").submit()
    })
    $("[id*=show_album_new_window]").click(function(){
        $("#album_new_form").dialog("open")
    })
    $("#from_space_botton").click(function(){
        $("#from_local_botton").removeClass()
        $("#from_space_botton").addClass("bg_5 bor_t_2 bor_b_2 c_3")
        $("#from_local_botton").addClass("bg_4 c_3")
        $(".photo_content").hide()
        $(".choose_photo").show()
    })
    $("#from_local_botton").click(function(){
        $("#from_space_botton").removeClass()
        $("#from_local_botton").addClass("bg_5 bor_t_2 bor_b_2 c_3")
        $("#from_space_botton").addClass("bg_4 c_3")
        $(".choose_photo").hide()
        $(".photo_content").show()
    })
    ////////////
    $("#nav_"+$("#nav-id").val()).addClass("now")
    $("#nav_"+$("#nav-id").val()).append("<sup>Now</sup>")
    ////////////
    $("#user_nav_"+$("#user-nav-id").val()).append("<sup></sup>")
    ///////////
    $("#nav_app a").hover(function(){
        $("#nav_app_list").show()
    },function(){
        $("#nav_app_list").hide()
    })
    //blog comment form ajav submit
    $('#blog_comment_btn').click(function() {
        $("#comment_comment_editor").val(CKEDITOR.instances.comment_comment_editor.getData())
        if($("#comment_comment_editor").val() == ""){
            alert("\u8bf7输入留言内容!")
        }
        else{
            $("#blog_comment_form").ajaxSubmit({
                success : function(data) {
                    CKEDITOR.instances.comment_comment_editor.setData('')
                    $("#commentList").append(data)
                }
            });
        }      
        return false;
    });
    //
    $("[id*=fold_tag]").click(function(){
        if ($(this).attr("class") == "fold")
            $(this).attr("class","unfold")
        else
            $(this).attr("class","fold")
        $(this).parent().next().slideToggle()
    })
    $("[id*=catag]").click(function(){
        $("[id*=catag]").removeClass("current")
        $(this).addClass("current")
    })
})